package com.ltkj.baseplatform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ltkj.baseplatform.domain.vo.SerCommentDataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.baseplatform.domain.SerCommentData;
import com.ltkj.baseplatform.service.ISerCommentDataService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 评论管理Controller
 * 
 * @author ruoyi
 * @date 2023-10-16
 */
@Api(tags = "评论管理")
@RestController
@RequestMapping("/commentdata")
public class SerCommentDataController extends BaseController
{
    @Autowired
    private ISerCommentDataService serCommentDataService;


    /**
     * 查询评论管理列表
     */
    @ApiOperation("查询评论列表(小程序用)")
    @GetMapping("/applet/list")
    public TableDataInfo appletList(SerCommentData serCommentData)
    {
        startPage();
        List<SerCommentDataVo> list = serCommentDataService.selectAppletCommentDataList(serCommentData);
        return getDataTable(list);
    }

    /**
     * 查询评论管理列表
     */
    @ApiOperation("查询评论列表")
    @RequiresPermissions("baseplatform:commentdata:list")
    @GetMapping("/list")
    public TableDataInfo list(SerCommentData serCommentData)
    {
        startPage();
        List<SerCommentDataVo> list = serCommentDataService.selectSerCommentDataList(serCommentData);
        return getDataTable(list);
    }

    /**
     * 获取评论管理详细信息
     */
    @ApiOperation("获取评论管理详细信息")
    @RequiresPermissions("baseplatform:commentdata:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(serCommentDataService.selectSerCommentDataById(id));
    }

    /**
     * 新增评论管理
     */
    @ApiOperation("新增评论管理")
    @RequiresPermissions("baseplatform:commentdata:add")
    @Log(title = "评论管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SerCommentData serCommentData)
    {
        return toAjax(serCommentDataService.insertSerCommentData(serCommentData));
    }

    /**
     * 修改评论管理
     */
    @ApiOperation("修改评论管理")
    @RequiresPermissions("baseplatform:commentdata:edit")
    @Log(title = "评论管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SerCommentData serCommentData)
    {
        return toAjax(serCommentDataService.updateSerCommentData(serCommentData));
    }

    /**
     * 删除评论管理
     */
    @ApiOperation("删除评论管理")
    @RequiresPermissions("baseplatform:commentdata:remove")
    @Log(title = "评论管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(serCommentDataService.deleteSerCommentDataByIds(ids));
    }
    /**
     * 导出评论管理列表
     */
    /*@ApiOperation("导出评论管理列表")
    @RequiresPermissions("baseplatform:commentdata:export")
    @Log(title = "评论管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SerCommentData serCommentData)
    {
        List<SerCommentData> list = serCommentDataService.selectSerCommentDataList(serCommentData);
        ExcelUtil<SerCommentData> util = new ExcelUtil<SerCommentData>(SerCommentData.class);
        util.exportExcel(response, list, "评论管理数据");
    }*/
}
